ABSTRACT
This paper presents a novel method for generating a single polynomial approximation that produces correctly rounded results for all inputs of an elementary function for multiple representations. The generated polynomial approximation has the nice property that the first few lower degree terms produce correctly rounded results for specific representations of smaller bitwidths, which we call progressive performance. To generate such progressive polynomial approximations, we approximate the correctly rounded result and formulate the computation of correctly rounded polynomial approximations as a linear program similar to our prior work on the RLIBM project. To enable the use of resulting polynomial approximations in mainstream libraries, we want to avoid piecewise polynomials with large lookup tables. We observe that the problem of computing polynomial approximations for elementary functions is a linear programming problem in low dimensions, i.e., with a small number of unknowns. We design a fast randomized algorithm for computing polynomial approximations with progressive performance. Our method produces correct and fast polynomials that require a small amount of storage. A few polynomial approximations from our prototype have already been incorporated into LLVM’s math library.
- Mridul Aanjaneya, Jay P. Lim, and Santosh Nagarakatte. 2022. RLibm-Prog. https://github.com/rutgers-apl/rlibm-progGoogle Scholar
- Sylvie Boldo, Marc Daumas, and Ren-Cang Li. 2009. Formally Verified Argument Reduction with a Fused Multiply-Add. In IEEE Transactions on Computers. 58, 1139–1145. https://doi.org/10.1109/TC.2008.216 Google ScholarDigital Library
- Peter Borwein and Tamas Erdelyi. 1995. Polynomials and Polynomial Inequalities. Springer New York. isbn:9780387945095 lccn:95008374 https://doi.org/10.1007/978-1-4612-0793-1 Google ScholarCross Ref
- Nicolas Brunie, Florent de Dinechin, Olga Kupriianova, and Christoph Lauter. 2015. Code Generators for Mathematical Functions. In 2015 IEEE 22nd Symposium on Computer Arithmetic. 66–73. https://doi.org/10.1109/ARITH.2015.22 Google ScholarDigital Library
- Hung Tien Bui and Sofiene Tahar. 1999. Design and synthesis of an IEEE-754 exponential function. In Engineering Solutions for the Next Millennium. 1999 IEEE Canadian Conference on Electrical and Computer Engineering. 1, 450–455 vol.1. https://doi.org/10.1109/CCECE.1999.807240 Google ScholarCross Ref
- Sylvain Chevillard, John Harrison, Mioara Joldes, and Christoph Lauter. 2011. Efficient and accurate computation of upper bounds of approximation errors. In Theoretical Computer Science. 412, https://doi.org/10.1016/j.tcs.2010.11.052 Google ScholarDigital Library
- Sylvain Chevillard, Mioara Joldes, and Christoph Lauter. 2010. Sollya: An Environment for the Development of Numerical Codes. In Mathematical Software - ICMS 2010 (Lecture Notes in Computer Science, Vol. 6327). Springer, Heidelberg, Germany. 28–31. https://doi.org/10.1007/978-3-642-15582-6_5 Google ScholarCross Ref
- Sylvain Chevillard and Christopher Lauter. 2007. A Certified Infinite Norm for the Implementation of Elementary Functions. In Seventh International Conference on Quality Software (QSIC 2007). 153–160. https://doi.org/10.1109/QSIC.2007.4385491 Google ScholarCross Ref
- Kenneth L. Clarkson. 1995. Las Vegas Algorithms for Linear and Integer Programming When the Dimension is Small. J. ACM, 42, 2 (1995), March, 488–499. issn:0004-5411 https://doi.org/10.1145/201019.201036 Google ScholarDigital Library
- William J Cody and William M Waite. 1980. Software manual for the elementary functions. Prentice-Hall, Englewood Cliffs, NJ. https://doi.org/10.1137/1024023 Google ScholarDigital Library
- Catherine Daramy, David Defour, Florent Dinechin, and Jean-Michel Muller. 2003. CR-LIBM: A correctly rounded elementary function library. In Proceedings of SPIE Vol. 5205: Advanced Signal Processing Algorithms, Architectures, and Implementations XIII. 5205, https://doi.org/10.1117/12.505591 Google ScholarCross Ref
- Catherine Daramy-Loirat, David Defour, Florent de Dinechin, Matthieu Gallet, Nicolas Gast, Christoph Lauter, and Jean-Michel Muller. 2006. CR-LIBM A library of correctly rounded elementary functions in double-precision. Laboratoire de l’Informatique du Parallélisme. https://hal-ens-lyon.archives-ouvertes.fr/ensl-01529804Google Scholar
- Pavlos S. Efraimidis and Paul G. Spirakis. 2006. Weighted random sampling with a reservoir. Inform. Process. Lett., 97, 5 (2006), 181–185. issn:0020-0190 https://doi.org/10.1016/j.ipl.2005.11.003 Google ScholarDigital Library
- Laurent Fousse, Guillaume Hanrot, Vincent Lefèvre, Patrick Pélissier, and Paul Zimmermann. 2007. MPFR: A Multiple-precision Binary Floating-point Library with Correct Rounding. ACM Trans. Math. Software, 33, 2 (2007), Article 13, June, issn:0098-3500 https://doi.org/10.1145/1236463.1236468 Google ScholarDigital Library
- Ambros M. Gleixner, Daniel E. Steffy, and Kati Wolter. 2012. Improving the Accuracy of Linear Programming Solvers with Iterative Refinement. In Proceedings of the 37th International Symposium on Symbolic and Algebraic Computation (ISSAC ’12). Association for Computing Machinery, New York, NY, USA. 187–194. isbn:9781450312691 https://doi.org/10.1145/2442829.2442858 Google ScholarDigital Library
- David Goldberg. 1991. What Every Computer Scientist Should Know About Floating-point Arithmetic. In ACM Computing Surveys. 23, ACM, New York, NY, USA. 5–48. issn:0360-0300 https://doi.org/10.1145/103162.103163 Google ScholarDigital Library
- John Harrison. 1997. Floating point verification in HOL light: The exponential function. In Algebraic Methodology and Software Technology, Michael Johnson (Ed.). Springer Berlin Heidelberg, Berlin, Heidelberg. 246–260. https://doi.org/10.1007/BFb0000475 Google ScholarCross Ref
- John Harrison. 1997. Verifying the Accuracy of Polynomial Approximations in HOL. In International Conference on Theorem Proving in Higher Order Logics. https://doi.org/10.1007/BFb0028391 Google ScholarCross Ref
- John Harrison. 2009. HOL Light: An Overview. In Proceedings of the 22nd International Conference on Theorem Proving in Higher Order Logics, TPHOLs 2009, Stefan Berghofer, Tobias Nipkow, Christian Urban, and Makarius Wenzel (Eds.) (Lecture Notes in Computer Science, Vol. 5674). Springer-Verlag, Munich, Germany. 60–66. https://doi.org/10.1007/978-3-642-03359-9_4 Google ScholarDigital Library
- Claude-Pierre Jeannerod, Hervé Knochel, Christophe Monat, and Guillaume Revy. 2011. Computing Floating-Point Square Roots via Bivariate Polynomial Evaluation. IEEE Trans. Comput., 60, https://doi.org/10.1109/TC.2010.152 Google ScholarDigital Library
- Olga Kupriianova and Christoph Lauter. 2014. Metalibm: A Mathematical Functions Code Generator. In 4th International Congress on Mathematical Software. https://doi.org/10.1007/978-3-662-44199-2_106 Google ScholarCross Ref
- Vincent Lefèvre, Jean-Michel Muller, and Arnaud Tisserand. 1998. Toward correctly rounded transcendentals. IEEE Trans. Comput., 47, 11 (1998), 1235–1243. https://doi.org/10.1109/12.736435 Google ScholarDigital Library
- Jay Lim. 2021. Novel Polynomial Approximation Methods for Generating Correctly Rounded Elementary Functions. Ph.D. Dissertation. Rutgers University.Google Scholar
- Jay P. Lim, Mridul Aanjaneya, John Gustafson, and Santosh Nagarakatte. 2020. A Novel Approach to Generate Correctly Rounded Math Libraries for New Floating Point Representations. arxiv:2007.05344. Rutgers Department of Computer Science Technical Report DCS-TR-753.Google Scholar
- Jay P. Lim, Mridul Aanjaneya, John Gustafson, and Santosh Nagarakatte. 2021. An Approach to Generate Correctly Rounded Math Libraries for New Floating Point Variants. Proceedings of the ACM on Programming Languages, 6, POPL (2021), Article 29, Jan., 30 pages. https://doi.org/10.1145/3434310 Google ScholarDigital Library
- Jay P. Lim and Santosh Nagarakatte. 2021. High Performance Correctly Rounded Math Libraries for 32-bit Floating Point Representations. In 42nd ACM SIGPLAN Conference on Programming Language Design and Implementation (PLDI’21). https://doi.org/10.1145/3453483.3454049 Google ScholarDigital Library
- Jay P Lim and Santosh Nagarakatte. 2021. RLIBM-32: High Performance Correctly Rounded Math Libraries for 32-bit Floating Point Representations. arxiv:2104.04043. Rutgers Department of Computer Science Technical Report DCS-TR-754.Google Scholar
- Jay P. Lim and Santosh Nagarakatte. 2021. RLIBM-ALL: A Novel Polynomial Approximation Method to Produce Correctly Rounded Results for Multiple Representations and Rounding Modes. arxiv:2108.06756. Rutgers Department of Computer Science Technical Report DCS-TR-757.Google Scholar
- Jay P. Lim and Santosh Nagarakatte. 2022. One Polynomial Approximation to Produce Correctly Rounded Results of an Elementary Function for Multiple Representations and Rounding Modes. Proceedings of the ACM on Programming Languages, 6, POPL (2022), Article 3, Jan., 28 pages. https://doi.org/10.1145/3498664 Google ScholarDigital Library
- Tue Ly. 2021. Implement correctly rounded logf based on RLIBM library. https://github.com/llvm/llvm-project/commit/d08a801b5f5678af52c89d202e5f22e0d43a38cdGoogle Scholar
- Tue Ly. 2022. Implement correctly rounded log10f based on RLIBM library. https://github.com/llvm/llvm-project/commit/e581841e8cf46109acea92e1acb661c404fa62b9Google Scholar
- Tue Ly. 2022. Implement correctly rounded log2f based on RLIBM library. https://github.com/llvm/llvm-project/commit/63d2df003e9c198bfa70d448f8ad7b361cbb1351Google Scholar
- Nimrod Megiddo. 1984. Linear Programming in Linear Time When the Dimension Is Fixed. J. ACM, 31, 1 (1984), Jan., 114–127. issn:0004-5411 https://doi.org/10.1145/2422.322418 Google ScholarDigital Library
- Jean-Michel Muller. 2005. Elementary Functions: Algorithms and Implementation. Birkhauser. isbn:0817643729 https://doi.org/10.1007/978-1-4899-7983-4 Google ScholarCross Ref
- Santosh Nagarakatte, Mridul Aanjaneya, and Jay P. Lim. 2022. The RLIBM Project. https://www.cs.rutgers.edu/~santosh.nagarakatte/rlibm/Google Scholar
- NVIDIA. 2020. TensorFloat-32 in the A100 GPU Accelerates AI Training, HPC up to 20x. https://blogs.nvidia.com/blog/2020/05/14/tensorfloat-32-precision-format/Google Scholar
- Eugene Remes. 1934. Sur un procédé convergent d’approximations successives pour déterminer les polynômes d’approximation. Comptes rendus de l’Académie des Sciences, 198 (1934), 2063–2065.Google Scholar
- Jun Sawada. 2002. Formal verification of divide and square root algorithms using series calculation. In 3rd International Workshop on the ACL2 Theorem Prover and its Applications.Google Scholar
- Shane Story and Ping Tak Peter Tang. 1999. New algorithms for improved transcendental functions on IA-64. In Proceedings 14th IEEE Symposium on Computer Arithmetic. 4–11. https://doi.org/10.1109/ARITH.1999.762822 Google ScholarCross Ref
- Giuseppe Tagliavini, Stefan Mach, Davide Rossi, Andrea Marongiu, and Luca Benin. 2018. A transprecision floating-point platform for ultra-low power computing. In 2018 Design, Automation Test in Europe Conference Exhibition (DATE). 1051–1056. https://doi.org/10.23919/DATE.2018.8342167 Google ScholarCross Ref
- Ping-Tak Peter Tang. 1989. Table-Driven Implementation of the Exponential Function in IEEE Floating-Point Arithmetic. ACM Trans. Math. Software, 15, 2 (1989), June, 144–157. issn:0098-3500 https://doi.org/10.1145/63522.214389 Google ScholarDigital Library
- Ping-Tak Peter Tang. 1990. Table-Driven Implementation of the Logarithm Function in IEEE Floating-Point Arithmetic. ACM Trans. Math. Software, 16, 4 (1990), Dec., 378–400. https://doi.org/10.1145/98267.98294 Google ScholarDigital Library
- P. T. P. Tang. 1991. Table-lookup algorithms for elementary functions and their error analysis. In [1991] Proceedings 10th IEEE Symposium on Computer Arithmetic. 232–236. https://doi.org/10.1109/ARITH.1991.145565 Google ScholarCross Ref
- Lloyd N. Trefethen. 2012. Approximation Theory and Approximation Practice (Other Titles in Applied Mathematics). Society for Industrial and Applied Mathematics, USA. isbn:1611972396Google Scholar
- Abraham Ziv. 1991. Fast Evaluation of Elementary Mathematical Functions with Correctly Rounded Last Bit. ACM Trans. Math. Software, 17, 3 (1991), Sept., 410–423. issn:0098-3500 https://doi.org/10.1145/114697.116813 Google ScholarDigital Library
Index Terms
- Progressive polynomial approximations for fast correctly rounded math libraries
Recommendations
Fast Polynomial Evaluation for Correctly Rounded Elementary Functions using the RLIBM Approach
CGO 2023: Proceedings of the 21st ACM/IEEE International Symposium on Code Generation and OptimizationThis paper proposes fast polynomial evaluation methods for correctly rounded elementary functions generated using our RLibm approach. The resulting functions produce correct results for all inputs with multiple representations and rounding modes. ...
One polynomial approximation to produce correctly rounded results of an elementary function for multiple representations and rounding modes
Mainstream math libraries for floating point (FP) do not produce correctly rounded results for all inputs. In contrast, CR-LIBM and RLIBM provide correctly rounded implementations for a specific FP representation with one rounding mode. Using such ...
Comments